package models;

import play.db.ebean.Model;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.List;

@Entity
public class Spurningar extends Model {

    @Id
    public Long id;
    public String spurning;
    public String username;

    public Spurningar(String spurning, String username) {
        spurning = spurning;
        this.username = username;
    }

    public static Model.Finder<Long,Spurningar> find = new Model.Finder(Long.class, Spurningar.class);

    public static Spurningar create(String spurning, String user) {
        Spurningar project = new Spurningar(spurning, user);
        project.save();
        return project;
    }

    public static List<Spurningar> findInvolving(String user) {
        return find.where()
                .eq("members.email", user)
                .findList();
    }
}